package com.corpgovernment.job.controller.vo.jobtype;

import com.corpgovernment.job.dao.entity.db.JobTypeDo;
import com.ctrip.corp.obt.generic.utils.CollectionUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author ldma
 * @date 2024/1/9
 */
@Data
public class ListAllJobTypeRespVo {

    private List<JobType> jobTypeTree;

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class JobType {
        private Long jobTypeId;
        private String jobTypeName;
        private String jobTypeCode;
        private Integer jobCount;
        private List<JobType> children;

        public JobType(JobTypeDo jobTypeDo, Map<Long, Integer> jobCountMap) {
            this.jobTypeId = jobTypeDo.getId();
            this.jobTypeName = jobTypeDo.getName();
            this.jobTypeCode = jobTypeDo.getCode();
            this.jobCount = jobCountMap.getOrDefault(jobTypeDo.getId(), 0);
        }
    }

}
